# -*- coding: utf-8 -*-
# Part of Odoo. See LICENSE file for full copyright and licensing details.

from odoo import api, fields, models, _


class CompanyConfigMixin(models.AbstractModel):
    _name = "fp.company.config.mixin"
    _description = "Company Config Mixin"
    # _order = 'sequence, name'

    company_id = fields.Many2one(
        'res.company', 'Company', required=True, index=True,
        default=lambda self: self.env.company)

    name = fields.Char(
        string='Name', related='company_id.name', store=True)

    tin = fields.Char(
        string='TIN', related="company_id.partner_id.vat", store=True)

    appkey = fields.Char(string='Appkey')
    app_secret = fields.Char(string='App Secret')

    _sql_constraints = [
        ('company_id_key', 'UNIQUE (company_id)',
         'You can not set two times for the same company !')
    ]
